package com.qf.day11;
import java.util.Iterator;
import java.util.Random;
/**
 * 产生10个随机的字符串
 */

public class StrIterator implements Iterator<String> {
    private int count = 0;
    private Random random = new Random();

    @Override
    public boolean hasNext() {
        return count < 10;
    }

    @Override
    public String next() {

        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < 10; i++) {
            sb.append((char) ('a' + random.nextInt(26)));
        }

        String randomString = sb.toString();
        count++;
        return randomString;
    }

    public static void main(String[] args) {
        StrIterator iterator = new StrIterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }
}